package com.tuzhi.sys.service.impl;

import com.tuzhi.base.jpa.repository.BaseRepo;
import com.tuzhi.base.service.impl.AbsBaseService;
import com.tuzhi.sys.jpa.entity.SysAuthEntity;
import com.tuzhi.sys.jpa.entity.SysDeptEntity;
import com.tuzhi.sys.jpa.repository.SysAuthRepo;
import com.tuzhi.sys.jpa.repository.SysDeptRepo;
import com.tuzhi.sys.service.SysAuthService;
import com.tuzhi.sys.service.SysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SysAuthServiceImpl  extends AbsBaseService<SysAuthEntity, Long> implements SysAuthService {
    @Autowired
    SysAuthRepo repo;
    @Override
    protected BaseRepo getThisRepo() {
        return repo;
    }

    @Override
    public List<Long> getAuthIds(Long roleId) {
        List<Long> ids=new ArrayList<>();
        SysAuthEntity sysAuthEntity = new SysAuthEntity();
        sysAuthEntity.setAuthId(roleId);
        sysAuthEntity.setAuthType(SysAuthEntity.Type.ROLE.getValue());
        sysAuthEntity.setResourceType(SysAuthEntity.ResourceType.Menu.getValue());
        List<SysAuthEntity> all = findAll(sysAuthEntity);
        all.forEach(sysAuth -> {
            ids.add(sysAuth.getResourceId());
        });
        return ids;
    }
}
